package com.trustasia.action;

import javax.annotation.Resource;

import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.trustasia.service.UserService;
@org.springframework.stereotype.Controller("userController")
@RequestMapping("/user")
@SessionAttributes({"u","a"})
public class UserController{
	
	@Resource
	private UserService userService;
	
	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	
	//头文件信息没有 name=**
	@RequestMapping(params="method=reg",headers="!name")
	public String reg(@RequestParam("name") String uname){
		System.out.println("control ...");
		userService.add(uname);
		return "login";
	}
	
	@RequestMapping(params="method=find")
	public String find(@RequestParam("name") String uname ,ModelMap map){
		System.out.println("conrol find ......");
		userService.find(uname);
		map.addAttribute("u", uname);
		return "reg";
	}
	
}
